<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" errorPage="index.jsp"%>
<%
	String valorStr = request.getParameter("valor");
	int valor = -1;
	if (valorStr != null && !valorStr.equals("")) {
		valor = Integer.parseInt(valorStr);
	}
	if (valor == -1) {
		request.setAttribute("erro", "Valor inválido. Por favor, informe novamente (um valor inteiro)!");
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tabuada Específica</title>
</head>
<body>
<h2>Tabuada de <%= valor %></h2>
<table border="1">
	<% for (int j = 1; j <= 9; j++ )  { %>
		<tr><td width="30" align="center"><%= valor %></td>
			<td width="30" align="center">X</td>
			<td width="30" align="center"><%= j %></td>
			<td width="30" align="center"><%= valor * j %></td>
		</tr>
	<% } %>
</table>
</body>
</html>